package com.seguriapp.base;

import java.util.List;

import org.hibernate.SessionFactory;

/**
 * Provides a common interface for Data Access Objects (DAOs).
 * 
 * @author Tania Gonzales(taniadgv@gmail.com)
 */
public interface GenericDao<T extends BaseEntity> {

  /**
   * Returns an entity by id.
   * 
   * @param id
   *          The id of the entity.
   * @return An instance of the entity or null if the entity does not exist.
   */
  T findById(Long id);

  /**
   * Deletes an entity from the database.
   * 
   * @param entity
   *          The entity to delete. Cannot be null.
   */
  void delete(T entidad);

  /**
   * Persists an entity to the database.
   * 
   * @param entity
   *          The entity to update. Cannot be null.
   */
  void save(T entidad);

  /**
   * Returns an entity list.
   * 
   */
  List<T> list();

  /**
   * Sets a sessionFactory bean
   * 
   * @param sessionFactory
   *          the been to use
   */
  void setSessionFactoryBean(SessionFactory sessionFactory);

}
